package cn.zymx.webTM.web.config;

import cn.zymx.webTM.web.webSocket.HandshakeInterceptor;
import cn.zymx.webTM.web.webSocket.WebSocketHander;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * Created by zhuqiang on 2015/6/23 0023.
 */
@Configuration
@EnableWebSocket//开启websocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new WebSocketHander(), "/echo").addInterceptors(new HandshakeInterceptor()).setAllowedOrigins("*");
        registry.addHandler(new WebSocketHander(), "/sockjs/echo").addInterceptors(new HandshakeInterceptor()).setAllowedOrigins("*").withSockJS();
    }

}
